package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.ClientTransferRecord;
import cn.wolfcode.crm.mapper.ClientTransferRecordMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IClientTransferRecordService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ClientTransferRecordImpl implements IClientTransferRecordService {
    @Autowired
    private ClientTransferRecordMapper transferRecordMapper;

    public void saveOrUpdate(ClientTransferRecord entity) {
            transferRecordMapper.insert(entity);
    }


    public PageResult query(QueryObject qo) {
        int count = transferRecordMapper.queryCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.emptyList());
        }
        List<ClientTransferRecord> transferRecords = transferRecordMapper.queryList(qo);
        return new PageResult(count, transferRecords);
    }
}
